home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPSETUP.ZIP / APPTOOLS.C < prev    next >
C/C++ Source or Header  |  1993-06-10  |  4KB  |  128 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <shellapi.h>
  5. #include <io.h>
  6. #include <stdarg.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <direct.h>
  10. #include <string.h>
  11. #include "appsetup.h"
  12.  
  13. /*--------------------------------------------------------------------------*/
  14. /* FUNCTION: OkMsgBox(char *szCaption, char *szFormat, ...)            */
  15. /*                                        */
  16. /* PURPOSE:  Display in an OKmessageBox a given text                */
  17. /*--------------------------------------------------------------------------*/
  18. VOID OkMsgBox(char *szCaption, char *szFormat, ...)
  19.     {
  20.     char *pArguments;
  21.  
  22.     pArguments = (char *) &szFormat + sizeof(szFormat);
  23.     vsprintf(szBuffer, szFormat, pArguments);
  24.     MessageBeep(0);
  25.     MessageBox(NULL, szBuffer, szCaption, MB_OK);
  26.     }
  27.  
  28. /*--------------------------------------------------------------------------*/
  29. /* FUNCTION: ErrorMsgBox(char *szCaption, char *szFormat, ...)            */
  30. /*                                        */
  31. /* PURPOSE:  Display in an ErrormessageBox a given text                */
  32. /*--------------------------------------------------------------------------*/
  33. VOID ErrorMsgBox(char *szCaption, char *szFormat, ...)
  34.     {
  35.     char *pArguments;
  36.  
  37.     pArguments = (char *) &szFormat + sizeof(szFormat);
  38.     vsprintf(szBuffer, szFormat, pArguments);
  39.     MessageBeep(MB_ICONEXCLAMATION);
  40.     MessageBox(NULL, szBuffer, szCaption, MB_OK | MB_ICONEXCLAMATION);
  41.     }
  42.  
  43. /*--------------------------------------------------------------------------*/
  44. VOID LoadIconFromFile(HICON *hIcon, int i)
  45.     {
  46.     MaxIconNumber[i] = (int) ExtractIcon(hInst, AppButton[i].IcoName, -1);
  47.     AppButton[i].IconNumber = min(MaxIconNumber[i]-1, AppButton[i].IconNumber);
  48.     *hIcon = ExtractIcon(hInst, AppButton[i].IcoName, AppButton[i].IconNumber);
  49.     if(*hIcon == (HICON) 1)
  50.     *hIcon = NULL;
  51.     }
  52.  
  53. /*--------------------------------------------------------------------------*/
  54. HBRUSH SetColorLightGray(HWND hwnd, HDC hdc)
  55.     {
  56.     POINT point;
  57.  
  58.     SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
  59.     SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
  60.     point.x = point.y = 0;
  61.     ClientToScreen(hwnd, &point);
  62.     SetBrushOrg(hdc, point.x, point.y);
  63.     return GetStockBrush(LTGRAY_BRUSH);
  64.     }
  65.  
  66. /*--------------------------------------------------------------------------*/
  67. HBRUSH SetColorStaticText(HWND hwnd, HDC hdc)
  68.     {
  69.     POINT point;
  70.  
  71.     SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
  72.     SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
  73.     point.x = point.y = 0;
  74.     ClientToScreen(hwnd, &point);
  75.     SetBrushOrg(hdc, point.x, point.y);
  76.     return GetStockBrush(LTGRAY_BRUSH);
  77.     }
  78.  
  79. /*-------------------------------------------------------------------------*/
  80. VOID LoadExeIcon(HICON *hIcon, int iCurrent)
  81.     {
  82.     strcpy(szBuffer, AppButton[iCurrent].IcoName);
  83.     strcpy(AppButton[iCurrent].IcoName, AppButton[iCurrent].ProgName);
  84.     DestroyIcon(*hIcon);
  85.     AppButton[iCurrent].IconNumber = 0;
  86.     LoadIconFromFile(hIcon, iCurrent);
  87.     if(*hIcon == NULL)
  88.     {
  89.     strcpy(AppButton[iCurrent].IcoName, szBuffer);
  90.     LoadIconFromFile(hIcon, iCurrent);
  91.     }
  92.     else
  93.     AppButton[iCurrent].ButtonLook = 1;
  94.     Edit_SetText(hwndEdit[3], AppButton[iCurrent].IcoName);
  95.     UpdateNextButtons(iCurrent);
  96.     }
  97.  
  98. /*--------------------------------------------------------------------------*/
  99. BOOL IsAppBarShell(VOID)
  100.     {
  101.     char ShellString[MAXFILECHARS];
  102.  
  103.     GetPrivateProfileString("boot", "shell", "  ", ShellString, MAXFILECHARS-1, "system.ini");
  104.     if(strstr((char *) AnsiLower((char FAR *)ShellString),"appbar.exe"))
  105.     return TRUE;
  106.     else
  107.     return FALSE;
  108.     }
  109.  
  110.  
  111. /*--------------------------------------------------------------------------*/
  112. HWND GetAppBarWindow(VOID)
  113.     {
  114.     HWND hWhatEver = GetActiveWindow();
  115.     char szWinText[25];
  116.  
  117.      while (hWhatEver != NULL)
  118.     {
  119.     if(GetWindowText(hWhatEver, (LPSTR) szWinText, 24) != 0)
  120.         {
  121.         if(!lstrcmp(szWinText, "AppBar 4.0"))
  122.         return hWhatEver;
  123.         }
  124.     hWhatEver = GetWindow(hWhatEver, GW_HWNDNEXT);
  125.     }
  126.     return (HWND) NULL;
  127.     }
  128.